# Contributor: Díaz Urbaneja Diego <sodomon2@gmail.com>
# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=dhewm3
pkgver=1.5.2
pkgrel=0
pkgdesc="Doom 3 engine with native 64-bit support, SDL, and OpenAL"
url="https://dhewm3.org/"
arch="all !riscv64"
license="GPL-3.0-only"
depends="curl libogg libpng libvorbis"
makedepends="cmake libjpeg-turbo-dev libogg-dev libpng-dev libvorbis-dev
	openal-soft-dev sdl2-dev zlib-dev"
options="!check" # make check not implemented
source="$pkgname-$pkgver.tar.gz::https://github.com/dhewm/dhewm3/archive/$pkgver.tar.gz
	dhewm3.desktop
	dhewm3.png"
builddir="$srcdir/$pkgname-$pkgver/neo"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DD3XP=1 \
		-DDEDICATED=1 \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 "$srcdir"/dhewm3.desktop "$pkgdir/usr/share/applications/dhewm3.desktop"
	install -Dm644 "$srcdir"/dhewm3.png "$pkgdir/usr/share/pixmaps/dhewm3.png"
}

sha512sums="
37aa177b6366e37e836a3fe1da5d7dd0869a8d3788a9a70b928355a161034c8b8b6b66b91f7383cdc0bd9c78cbf8fde1129c6ad6405a244069368fbf230e0137  dhewm3-1.5.2.tar.gz
377d34c4d9ab21b09a501431e1bf8d123d3655a47499a7664db85168e2f85b73c8792bc958026593299eac57449f813b10047beb302784cc53d096e1cc37efbd  dhewm3.desktop
11957d10fd685c5b7967c6baf7e6c75e6995f76a028fa0dba75c4d596e84acb4f9ab863c0ae0b4e164483ef089111f4b3eb31fd5c770f0e77048112210b60b97  dhewm3.png
"
